package com.oocl.jpa.controller;

import javax.annotation.Resource;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;

import com.oocl.jpa.pojo.Customer;
import com.oocl.jpa.service.CustomerService;

/**
 * @description: 
 * @author  XIEMI2
 * @date Aug 9, 2017 5:49:22 PM
 * @version 1.0
 */
@Controller
@RequestMapping("/customer")
public class CustomerController {
	
	@Resource(name="customerService")
	private CustomerService customerService;

	@RequestMapping("/register")
	public String register(Customer cust){
		System.out.println("当前    注册  的cust信息： "+cust.toString());
		Customer customer = customerService.register(cust);
		if(customer != null){
			return "redirect: ../login";
		}else{
			return "redirect: ../register";
		}
		
	}
	
	@RequestMapping("/login")
	public String login(Customer cust){
		System.out.println("当前  登录  的cust信息： "+cust.toString());
		Customer customer = customerService.login(cust.getCname(), cust.getPassword());
		if(customer != null){
			return "success";
		}else{
			return "redirect: ../register";
		}
	}
	
}


